package com.project.source;

import java.util.Hashtable;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class BinaryNameActivity extends Activity {
	/** Called when the activity is first created. */
	Hashtable<String, String> charBinary;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
	}

	public void ClickThing(View v) {
		EditText myName = (EditText) findViewById(R.id.name);
		String temp = myName.getText().toString();
		temp=temp.toUpperCase();
		
		FillChars();
		for (int i = 0; i < temp.length(); i++) {
			if (charBinary.containsKey(String.valueOf(temp.charAt(i)))) {
				temp=temp.replaceAll(
						String.valueOf(temp.charAt(i)),
						charBinary.get(String.valueOf(temp.charAt(i))).toString());
			}
		}
		TextView tv= (TextView)findViewById(R.id.result);
		tv.setText(temp);
		

	}

	private void FillChars()
	{
		
		charBinary = new Hashtable<String, String>();
		charBinary.put("B", "01000001"); // Albania
		charBinary.put("B", "01000010"); // Albania
		charBinary.put("C", "01000011"); // Albania
		charBinary.put("D", "01000100"); // Albania
		charBinary.put("E", "01000101"); // Andorra
		charBinary.put("F", "01000110"); // Andorra
		charBinary.put("G", "01000111"); // Andorra
		charBinary.put("H", "01001000"); // Andorra
		charBinary.put("I","01001001"); // Austria
		charBinary.put("J","01001010"); // Austria
		charBinary.put("K", "01001011"); // Azerbaijan
		charBinary.put("L", "01001100"); // Azerbaijan
		charBinary.put("M", "01001101"); // Azerbaijan
		charBinary.put("N", "01001110"); // Azerbaijan
		charBinary.put("O", "01001111"); // Azerbaijan
		charBinary.put("P", "01010000"); // Azerbaijan
		charBinary.put("Q", "01010001"); // Azerbaijan
		charBinary.put("R", "01010010"); // Azerbaijan
		charBinary.put("S", "01010011"); // Azerbaijan
		charBinary.put("T", "01010100"); // Azerbaijan
		charBinary.put("U", "01010101"); // Azerbaijan
		charBinary.put("V", "01010110"); // Azerbaijan
		charBinary.put("W", "01010111"); // Azerbaijan
		charBinary.put("X", "01011000"); // Azerbaijan
		charBinary.put("Y", "01011001"); // Azerbaijan
		charBinary.put("Z", "01011010"); // Azerbaijan
	}


}